import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
////        int [][]x = {{1,2},{3,4,5},{6,7,8,9}};
////        int [][]y = x;
////        System.out.println(y[2][1]);


//        int [] list1 = {2, 4, 7, 10};
//        Arrays.fill (list1, 7);//fill是填充方法
//        System.out.println(Arrays.toString(list1));
//        int [] list2 = {2, 4, 7, 10};
//        System.out.println(Arrays.toString(list2));
//        System.out.println(Arrays.equals(list1,list2));//这个方法会比较两个数组的每个元素，
//        // 如果所有元素都相同，返回true，否则返回false。



        int[][] array = {{1,3,5},{-3,6,0},{13,-5,7},{-2,19,25}};
        int count = 0;
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print("  "+array[i][j]);
                count++;
                if(count % array[0].length == 0){
                    System.out.println();
                }
            }
        }

        int[][] x = transposeMatrix(array);

        for (int i = 0; i < x.length; i++) {
            for (int j = 0; j < x[0].length; j++) {
                System.out.print(x[i][j]);
                count++;
                if(count % x[0].length == 0){
                    System.out.println();
                }
            }
        }
    }
    public static int[][] transposeMatrix(int[][] matrix) {
        int rows = matrix.length;
        int cols = matrix[0].length;
        int[][] transposedMatrix = new int[cols][rows];

        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                transposedMatrix[j][i] = matrix[i][j];
            }
        }

        return transposedMatrix;
    }
}
